package cn.moukou.tongji.ihealth.auth.controller;

import cn.moukou.tongji.ihealth.auth.pojo.Admin;
import cn.moukou.tongji.ihealth.auth.service.AuthService;
import cn.moukou.tongji.ihealth.core.bean.Resp;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/ihealth/auth")
public class ApiController {

    @Autowired
    AuthService authService;

    @PostMapping("/login")
    public Resp<Object> auth(@RequestParam("uid") String uid,
                             @RequestParam("password") String password,
                             @RequestParam("role") String role) {
        switch (role) {
            case "doctor":
                return authService.authDoctor(uid, password);
            case "admin":
                return authService.authAdmin(uid, password);
            case "patient":
                return authService.authPatient(uid, password);
            default:
                return Resp.fail("非正常的role");
        }
    }

    @GetMapping("/ping")
    public Resp<Object> ping() {
        return Resp.ok("pong");
    }

}
